#include "trap.h"
#include "instr_def.h"
#include "instr_test.h"
    .set noreorder
    .set noat
    .globl main
    .text
main:    
    # SLLV 1
    li $s1, 0x0
    nop
    nop
    SLLV_TEST(0x00000020, 0x42adf91d, 0x42adf91d) # 1
    nop
    nop
    SLLV_TEST(0x00000008, 0x555b05c6, 0x5b05c600) # 2
    nop
    nop
    SLLV_TEST(0xffffffff, 0x24ac79b4, 0x00000000) # 3
    nop
    nop
    SLLV_TEST(0x00000000, 0x210c4488, 0x210c4488) # 4
    nop
    nop
    SLLV_TEST(0x39457256, 0x7d54a866, 0x19800000) # 5
    nop
    nop
    SLLV_TEST(0xeabbbbac, 0x9fcc8a42, 0xc8a42000) # 6 
    nop
    nop
    SLLV_TEST(0xeca485a1, 0x00000001, 0x00000002) # 7 
    nop
    nop
    SLLV_TEST(0x0913c7b8, 0x6c5f982c, 0x2c000000) # 8 
    nop
    nop
    SLLV_TEST(0x2890ffb0, 0x45d5eda8, 0xeda80000) # 9 
    nop
    nop
    SLLV_TEST(0x2a19dd40, 0xa87971e0, 0xa87971e0) # 10 
    nop
    nop
    SLLV_TEST(0xedededee, 0xedededee, 0x7b7b8000) # 11 
    nop
    nop
    SLLV_TEST(0xe4b62124, 0x6f1772b8, 0xf1772b80) # 12 
    nop
    nop
    SLLV_TEST(0x0000000a, 0xedededee, 0xb7b7b800) # 13 
    nop
    nop
    SLLV_TEST(0x7fffffff, 0x7fffffff, 0x80000000) # 14 
    nop
    nop
    SLLV_TEST(0x80000000, 0x80000000, 0x80000000) # 15 
    li $k0, 1
    
    # SLL 2
    li $s1, 0x0
    nop
    nop
    SLL_TEST(0x42adf91d, 0xc8e80000, 0x13) # 1
    nop
    nop
    SLL_TEST(0x555b05c6, 0x5b05c600, 0x08) # 2
    nop
    nop
    SLL_TEST(0x24ac79b4, 0x00000000, 0x1f) # 3
    nop
    nop
    SLL_TEST(0x210c4488, 0x210c4488, 0x00) # 4
    nop
    nop
    SLL_TEST(0x8d54a866, 0x66000000, 0x18) # 5
    nop
    nop
    SLL_TEST(0xeabbbbac, 0xddd60000, 0x0f) # 6 
    nop
    nop
    SLL_TEST(0x00000001, 0x00000004, 0x02) # 7 
    nop
    nop
    SLL_TEST(0x0913c7b8, 0x3c7b8000, 0x0c) # 8 
    nop
    nop
    SLL_TEST(0x2890ffb0, 0x121ff600, 0x05) # 9 
    nop
    nop
    SLL_TEST(0x80000000, 0x00000000, 0x17) # 10 
    nop
    nop
    SLL_TEST(0xedededee, 0x6f6f7000, 0x0b) # 11 
    nop
    nop
    SLL_TEST(0xe4b62124, 0xd8849000, 0x0a) # 12 
    nop
    nop
    SLL_TEST(0x0000000a, 0x00000000, 0x1f) # 13 
    nop
    nop
    SLL_TEST(0x7fffffff, 0x80000000, 0x1f) # 14 
    nop
    nop
    SLL_TEST(0x80000000, 0x00000000, 0x0f) # 15 
    li $k0, 2

    # SRAV 3
    li $s1, 0x0
    nop
    nop
    SRAV_TEST(0x00000020, 0x42adf91d, 0x42adf91d) # 1
    nop
    nop
    SRAV_TEST(0x00000008, 0x555b05c6, 0x00555b05) # 2
    nop
    nop
    SRAV_TEST(0xffffffff, 0x24ac79b4, 0x00000000) # 3
    nop
    nop
    SRAV_TEST(0x00000000, 0x210c4488, 0x210c4488) # 4
    nop
    nop
    SRAV_TEST(0x39457256, 0x7d54a866, 0x000001f5) # 5
    nop
    nop
    SRAV_TEST(0xeabbbbac, 0x9fcc8a42, 0xfff9fcc8) # 6
    nop
    nop
    SRAV_TEST(0xeca485a1, 0x00000001, 0x00000000) # 7 
    nop
    nop
    SRAV_TEST(0x0913c7b8, 0x6c5f982c, 0x0000006c) # 8 
    nop
    nop
    SRAV_TEST(0x2890ffb0, 0x45d5eda8, 0x000045d5) # 9 
    nop
    nop
    SRAV_TEST(0x2a19dd40, 0xa87971e0, 0xa87971e0) # 10 
    nop
    nop
    SRAV_TEST(0xedededee, 0xedededee, 0xffffb7b7) # 11 
    nop
    nop
    SRAV_TEST(0xe4b62124, 0x6f1772b8, 0x06f1772b) # 12 
    nop
    nop
    SRAV_TEST(0xc9c9c9ca, 0xedededee, 0xfffb7b7b) # 13 
    nop
    nop
    SRAV_TEST(0x7fffffff, 0x7fffffff, 0x00000000) # 14 
    nop
    nop
    SRAV_TEST(0x80000000, 0x80000000, 0x80000000) # 15 
    li $k0, 3
    
    # SRA 4
    li $s1, 0x0
    nop
    nop
    SRA_TEST(0x42adf91d, 0x00000855, 0x13) # 1
    nop
    nop
    SRA_TEST(0x555b05c6, 0x00555b05, 0x08) # 2
    nop
    nop
    SRA_TEST(0x24ac79b4, 0x00000000, 0x1f) # 3
    nop
    nop
    SRA_TEST(0x210c4488, 0x210c4488, 0x00) # 4
    nop
    nop
    SRA_TEST(0x8d54a866, 0xffffff8d, 0x18) # 5
    nop
    nop
    SRA_TEST(0xeabbbbac, 0xffffd577, 0x0f) # 6 
    nop
    nop
    SRA_TEST(0x00000001, 0x00000000, 0x02) # 7 
    nop
    nop
    SRA_TEST(0x0913c7b8, 0x0000913c, 0x0c) # 8 
    nop
    nop
    SRA_TEST(0x2890ffb0, 0x014487fd, 0x05) # 9 
    nop
    nop
    SRA_TEST(0x80000000, 0xffffff00, 0x17) # 10 
    nop
    nop
    SRA_TEST(0xedededee, 0xfffdbdbd, 0x0b) # 11 
    nop
    nop
    SRA_TEST(0xe4b62124, 0xfff92d88, 0x0a) # 12 
    nop
    nop
    SRA_TEST(0x0000000a, 0x00000000, 0x1f) # 13 
    nop
    nop
    SRA_TEST(0x7fffffff, 0x00000000, 0x1f) # 14 
    nop
    nop
    SRA_TEST(0x80000000, 0xffff0000, 0x0f) # 15 
    li $k0, 4

    # SRLV 5
    li $s1, 0x0
    nop
    nop
    SRLV_TEST(0x00000020, 0x42adf91d, 0x42adf91d) # 1
    nop
    nop
    SRLV_TEST(0x00000008, 0x555b05c6, 0x00555b05) # 2
    nop
    nop
    SRLV_TEST(0xffffffff, 0x24ac79b4, 0x00000000) # 3
    nop
    nop
    SRLV_TEST(0x00000000, 0x210c4488, 0x210c4488) # 4
    nop
    nop
    SRLV_TEST(0x39457256, 0x7d54a866, 0x000001f5) # 5
    nop
    nop
    SRLV_TEST(0xeabbbbac, 0x9fcc8a42, 0x0009fcc8) # 6 
    nop
    nop
    SRLV_TEST(0xeca485a1, 0x00000001, 0x00000000) # 7 
    nop
    nop
    SRLV_TEST(0x0913c7b8, 0x6c5f982c, 0x0000006c) # 8 
    nop
    nop
    SRLV_TEST(0x2890ffb0, 0x45d5eda8, 0x000045d5) # 9 
    nop
    nop
    SRLV_TEST(0x2a19dd40, 0xa87971e0, 0xa87971e0) # 10 
    nop
    nop
    SRLV_TEST(0xedededee, 0xedededee, 0x0003b7b7) # 11 
    nop
    nop
    SRLV_TEST(0xe4b62124, 0x6f1772b8, 0x06f1772b) # 12 
    nop
    nop
    SRLV_TEST(0x0000000a, 0xedededee, 0x003b7b7b) # 13 
    nop
    nop
    SRLV_TEST(0x7fffffff, 0x7fffffff, 0x00000000) # 14 
    nop
    nop
    SRLV_TEST(0x80000000, 0x80000000, 0x80000000) # 15 
    li $k0, 5

    # SRL 6
    li $s1, 0x0
    nop
    nop
    SRL_TEST(0x42adf91d, 0x000042ad, 0x10) # 1 TEST ERROR
    nop
    nop
    SRL_TEST(0x555b05c6, 0x00555b05, 0x08) # 2
    nop
    nop
    SRL_TEST(0x24ac79b4, 0x00000000, 0x1f) # 3
    nop
    nop
    SRL_TEST(0x210c4488, 0x210c4488, 0x00) # 4
    nop
    nop
    SRL_TEST(0x8d54a866, 0x0000008d, 0x18) # 5
    nop
    nop
    SRL_TEST(0xeabbbbac, 0x0001d577, 0x0f) # 6 
    nop
    nop
    SRL_TEST(0x00000001, 0x00000000, 0x02) # 7 
    nop
    nop
    SRL_TEST(0x0913c7b8, 0x0000913c, 0x0c) # 8 
    nop
    nop
    SRL_TEST(0x2890ffb0, 0x014487fd, 0x05) # 9 
    nop
    nop
    SRL_TEST(0x80000000, 0x00000100, 0x17) # 10 
    nop
    nop
    SRL_TEST(0xedededee, 0x001dbdbd, 0x0b) # 11 
    nop
    nop
    SRL_TEST(0xe4b62124, 0x00392d88, 0x0a) # 12 
    nop
    nop
    SRL_TEST(0x00c0fb0a, 0x00000030, 0x12) # 13 
    nop
    nop
    SRL_TEST(0x7fffffff, 0x00000000, 0x1f) # 14 
    nop
    nop
    SRL_TEST(0x80000000, 0x00010000, 0x0f) # 15 
    li $k0, 6

    li $k1, 0x12345678
    HIT_GOOD_TRAP		# stop temu

res_error: 
    li $s1, 0x11111111
    HIT_BAD_TRAP		# stop temu